package com.ruoyi.project.drug.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.drug.domain.DruPurchaseDrug;
import com.ruoyi.project.drug.service.DruPurchaseDrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Transactional
@RequestMapping("/drug/druPurchaseDrug")
public class DruPurchaseDrugController extends BaseController {


    @Autowired
    private DruPurchaseDrugService druPurchaseDrugService;


    /**
     * 根据添加的药品信息集合对订单药品信息进行修改新增
     *
     * @param drugList  药品信息集合
     * @return  返回1成功
     */
    @PreAuthorize("@ss.hasAnyPermi('drug:purchase:update')")
    @PostMapping("/suboptimal")
    public AjaxResult suboptimal(@RequestBody List<DruPurchaseDrug> drugList){

        int suboptimal = druPurchaseDrugService.suboptimal(drugList);

        return toAjax(suboptimal);
    }
}
